//
//  CommentBar.m
//  CoolFM
//
//  Created by 曹曹 on 16/9/22.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "CommentBar.h"
#import "UIView+Frame.h"
#import "GX_Button.h"

@implementation CommentBar

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return self;
}

- (void)setUp {
    self.backgroundColor = [UIColor whiteColor];
    CGRect selfFrame = self.bounds;
    CGFloat height = CGRectGetHeight(selfFrame) - 10;
    CGFloat margin = 5;
    /**
     * emoji btn
     */
    _emojiBtn = [GX_Button buttonWithType:UIButtonTypeCustom];
    [_emojiBtn setFrame:CGRectMake(margin, margin, height, height)];
    [_emojiBtn setImage:[UIImage imageNamed:@"face"] forState:UIControlStateNormal];
    [self addSubview:_emojiBtn];
    /**
     * textField
     */
    CGFloat textX = margin * 2 + height;
    CGFloat textY = margin;
    CGFloat textW = CGRectGetWidth(selfFrame) - margin * 4 - height * 3;
    CGFloat textH = height;
    _textField = [[UITextField alloc] initWithFrame:CGRectMake(textX, textY, textW, textH)];
    _textField.placeholder = @"我想说";
    _textField.borderStyle = UITextBorderStyleRoundedRect;
    [_textField setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [_textField setValue:[UIFont systemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
    [self addSubview:_textField];
    /**
     * send btn
     */
    _sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_sendBtn setFrame:CGRectMake(CGRectGetWidth(selfFrame) - height * 2 - margin, margin, height * 2, height)];
    [_sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [_sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_sendBtn setBackgroundColor:[UIColor lightGrayColor]];
    _sendBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    _sendBtn.layer.cornerRadius = 2;
    _sendBtn.layer.masksToBounds = YES;
    [self addSubview:_sendBtn];
}

@end
